package util.struts;

import java.util.Map;

import org.apache.struts2.util.StrutsTypeConverter;

public class ConvertStringToInteger extends StrutsTypeConverter {

	@SuppressWarnings("rawtypes")
	@Override
	public Object convertFromString(Map context, String[] values, Class clazz) {
		try {
			if (clazz == String.class) {
				if (!(values[0].equals("_empty")))
					return Integer.parseInt(values[0]);

			}
			if (clazz == int.class) {
				return values[0];
			}
			return values[0];
		} catch (Exception e) {
			return null;
			//e.getCause();
		}
	}

	@SuppressWarnings("rawtypes")
	@Override
	public String convertToString(Map arg0, Object arg1) {
		// TODO Auto-generated method stub
		return null;
	}

}
